USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[PlayerWeaponStatsSelectByPlayerId]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.PlayerWeaponStatsSelectByPlayerId
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	Player Victims Select By PlayerId
-- =============================================
CREATE PROCEDURE PlayerWeaponStatsSelectByPlayerId

			@Attacker_playerId varchar(30),
			@WeaponId int
	
AS
BEGIN


DECLARE @WeaponName varchar(50),
		@Kills int,
		@Deaths int,
		@KillDeathRatio varchar(8)

SELECT @Kills = COUNT(KillId) from [Kills]	WHERE Attacker_PlayerId = @Attacker_playerId AND Attacker_weaponId = @WeaponId
SELECT @Deaths = COUNT(KillId) from [Kills]	WHERE Victim_PlayerId = @Attacker_playerId AND Attacker_weaponId = @WeaponId
SELECT @WeaponName = WeaponFullName from [Weapons] WHERE WeaponId = @WeaponId
SET @KillDeathRatio = ''


SELECT @WeaponName AS [Weapon], @Kills AS [Kills], @Deaths AS [Deaths], 
@KillDeathRatio AS [KillDeathRatio], @WeaponId as [WeaponId]

END
GO

--  PlayerWeaponStatsSelectByPlayerId 'STEAM_0:1:16198379',1
